package com.war.dao.system;

import com.war.pojo.system.Supplier;
import com.war.pojo.system.Warehouse;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface SupplierDao {
    //查询供应商
    @Select("select * from sys_supplier")
    List<Supplier> selectAll();

    //查询供应商名称
    @Select("select name from sys_supplier")
    List<Supplier> selectName();

    //根据供应商名查供应商
    @Select("select * from sys_supplier where name=#{name}")
    Supplier selectByName(Supplier supplier);

    //根据id查供应商
    @Select("select * from sys_supplier where id=#{id}")
    Supplier selectById(Supplier supplier);

    //根据法人代表查供应商
    @Select("select * from sys_supplier where legal_person=#{legal_person}")
    Supplier selectByLP(Supplier supplier);

    //删除供应商
    @Delete("delete from sys_supplier where id=#{id}")
    int delSup(Supplier supplier);

    //修改供应商信息
    @Update("update sys_supplier set id=#{id}, name=#{name}, legal_person=#{legal_person}, tel=#{tel}, email=#{email} address=#{address}, begin_cooperation=#{begin_cooperation}, cooperation_years=#{cooperation_years}, buyer=#{buyer} where id=#{id}")
    int updateSup(Supplier supplier);

    //注册供应商
    @Insert("insert into sys_supplier(id, name, legal_person, tel, email, address, begin_cooperation, cooperation_years, buyer) value(#{id}, #{name}, #{legal_person}, #{tel}, #{email}, #{address}, #{begin_cooperation}, #{cooperation_years}, #{buyer})")
    int addSup(Supplier supplier);

}
